package view.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.CompletedTask;
import controller.factory.AbstractFactory;

public class ActionFindByTask implements Action {

	@Override
	public String execute(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String str = request.getParameter("taskID");
		if (str == null) {
			request.getSession().setAttribute("error",
					"Необходимо выбрать задание");
			return "/secured/preparedSearch.do";
		} else {
			Long idTask = Long.parseLong(str);
			List<CompletedTask> complitedTask = AbstractFactory.getNewInstance()
					.getDAOCompletedTask().getCompletedTasks(idTask);
			request.getSession().setAttribute("complitedTask", complitedTask);
			return "/secured/findByTask.jsp";
		}
	}
}
